﻿using System;
using Sireass.Dal;
using System.Data.SqlClient;
using Csla.Data;

namespace Sireass.DalSql
{
    public class ResponsableDal : IResponsableDal
    {

        private SqlParameter accion = null;
        private string nombreProcedimiento = null;


        public ResponsableDal()
        {
            accion = new SqlParameter("@Accion", System.Data.SqlDbType.SmallInt);
            nombreProcedimiento = "spSireassResponsable";
        }

        public System.Data.IDataReader Fetch()
        {
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("SqlServer"))
            {
                var cm = ctx.Connection.CreateCommand();
                cm.CommandType = System.Data.CommandType.StoredProcedure;
                cm.CommandText = nombreProcedimiento;
                cm.Parameters.AddWithValue("@Accion", AccionDal.AccionSP.CONSULTAR);
                return cm.ExecuteReader();
            }
        }

        public System.Data.IDataReader Fetch(long idResponsablePersona)
        {
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("SqlServer"))
            {
                var cm = ctx.Connection.CreateCommand();
                cm.CommandType = System.Data.CommandType.StoredProcedure;
                cm.CommandText = nombreProcedimiento;
                cm.Parameters.AddWithValue("@Accion", AccionDal.AccionSP.CONSULTAR);
                cm.Parameters.AddWithValue("@nId_Persona_Administrativo", idResponsablePersona);
                return cm.ExecuteReader();
            }
        }

    }
}
